package com.example.hospital.controller;

import com.example.hospital.dto.Result;
import com.example.hospital.entity.Doctor;
import com.example.hospital.service.DoctorService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/specialty")
@Tag(name = "Specialty", description = "科室相关接口")
public class SpecialtyController {
    @Resource
    private DoctorService doctorService;

    /**
     * 获取全部科室
     *
     * @return
     */
    @Operation(summary = "获取全部科室",
            description = "获取全部科室名",
            responses = {
                    @ApiResponse(responseCode = "200", description = "获取成功"),
                    @ApiResponse(responseCode = "400", description = "获取失败")
            }
    )
    @GetMapping
    public Result listSpecialties() {
        List<String> specialties = doctorService.list().stream().map(Doctor::getSpecialty).distinct().toList();
        return Result.success(specialties);
    }
}
